//
//  MYAliBeautyView.m
//  MiaoYin
//
//  Created by DarkWorld on 2021/11/25.
//  Copyright © 2021 thy. All rights reserved.
//

#import "MYAliBeautyView.h"
@interface MYAliBeautyView ()
/// 主视图
@property(nonatomic, strong) UIView *mainView;

@end
@implementation MYAliBeautyView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];

        [self initData];
        [self initView];

    }
    return self;
}

- (void)dealloc
{
}

#pragma mark - Intial Methods
/**
 初始化数据
 */
- (void)initData
{
}

/**
 初始化试图
 */
- (void)initView
{
    [self addMainView];
}
- (void)addMainView
{
    CGFloat  height = 187 +MY_BottomSafeMargin;

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, height)];
    view.backgroundColor = kColorAWithHex(0x191A1E, 0.8);
    [self addSubview:view];
    self.mainView = view;
    [view cornerByRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadius:16];
}
#pragma mark - Lazy Loads
- (void)show
{

    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self];
    self.mainView.top = self.height;
    [UIView animateWithDuration:0.25 animations:^{
        self.mainView.bottom = self.height;
    }];
}
- (void)dismiss
{
    self.mainView.backgroundColor = [UIColor clearColor];

    [UIView animateWithDuration:0.25 animations:^{
        self.mainView.top = self.height;

    } completion:^(BOOL finished) {

        [self removeFromSuperview];
     
        
    }];
    
}



@end
